<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/base.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
<link href="${ctsCss}/table.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%@ include file="/common/message-save.jsp" %>
<form id="annual-form" class="form-horizontal" action="${ctx}/rptAnnualController/<c:choose><c:when test="${rptAnnual.annualId == null}">insertAnnual</c:when><c:otherwise>updateAnnual</c:otherwise></c:choose>" method="post">
	<input type="hidden" id="annualId" name="annualId" value="${rptAnnual.annualId}"/>
<table>
	 <tr class="tab_grey">
      <td width="15%">版本名称：</td>
      <td width="35%"><input type="text" id="name" name="name" value="${rptAnnual.name }" required maxlength="50" style="width:150px" maxlength='25' /></td>
      <%-- <td width="15%">年度类型：</td>
      <td width="35%">
      	<gdata:select items="${codedic['10001']}" name="rptType" value="${rptAnnual.rptType}" headerKey="请选择" cssStyle="width:150px"/>
      </td> --%>
      <td width="15%">版本类型：</td>
      <td width="35%">
      	<gdata:select items="${codedic['10007']}" id="rptAttributeId" name="rptAttribute" value="${rptAnnual.rptAttribute}" headerKey="请选择" cssStyle="width:150px"/>
      </td>
     </tr>
     <tr class="tab_grey">
      <td width="15%">年度具体说明：</td>
      <td width="85%" colspan="3">
      	<textarea id="description" name="description" style="width:70%" cols="50" rows="2" maxlength="100" id="textfield4" >${rptAnnual.description}</textarea>
      </td>
     </tr>
     <tr class="tab_grey">
      <td width="15%">起始时间：</td>
      <td width="35%">
      	<input type="text" id="startTime" name="startTime" style="width:150px" class="Wdate" onclick="WdatePicker({skin:'blue',maxDate:'#F{$dp.$D(\'endTime\',{d:0});}'})" value="${rptAnnual.startTime }" required/>
      </td>
      <td width="15%">结束时间：</td>
      <td width="35%">
      	<input type="text" id="endTime" name="endTime" style="width:150px" class="Wdate" onclick="WdatePicker({skin:'blue',minDate:'#F{$dp.$D(\'startTime\',{d:0});}'})" value="${rptAnnual.endTime }" required/>
      </td>
     </tr>
     <tr class="tab_grey">
      <td width="15%">排序：</td>
      <td width="85%" colspan="3">
      	<input type="text" id="orderId" name="orderId" value="${rptAnnual.orderId }" class="number" maxlength="5" style="width:150px" maxlength='4' />
      	注：只能填数字，数字越大，排序越靠前
      </td>
     </tr>
</table>
<div  style="text-align: center;">
	<button type="button" class="btn btn-primary" id="saveBtn" onclick="annualSaveInfo();">保存</button>
	<button type="reset" class="btn" id="resetBtn">重置</button>
</div>
</form>
</body>
<script type="text/javascript">
$('#annual-form').validate();
function annualSaveInfo(){
	var rptAttributeId = $("#rptAttributeId").val();
	var annualId = $("#annualId").val();
	//判断annualId是否有值，如果没有值，说明是新增的，如果有值说明是修改
	if(annualId == null || annualId == ''){
		$.ajax({
			url:'${ctx}/rptAnnualController/isAnnualIdHave/'+rptAttributeId,
			type:'POST',
			cache:false,
			success:function(data){
				if(data == '1'){
					alert("当前已存在相应版本，如需添加，请先删除本年度的模板");
					return false;
				}else{
					$("#annual-form").submit();
				}
			}
		});
	}else{
		$("#annual-form").submit();
	}
	
}
</script>
</html>